﻿@model TimeReporting.Models.Project

@{
    ViewBag.Title = "Edit";
}

<h2>Edit</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Project</legend>

        @Html.HiddenFor(model => model.projectID)

        <div class="editor-label">
            @Html.LabelFor(model => model.title)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.title)
            @Html.ValidationMessageFor(model => model.title)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.client)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.client)
            @Html.ValidationMessageFor(model => model.client)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.managerName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.managerName)
            @Html.ValidationMessageFor(model => model.managerName)
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

Add member: 
@Html.DropDownList("projectnonMembers", String.Empty) 

<script type="text/javascript">
    $(document).ready(function () {
        $('#projectnonMembers').change(function () {
            //alert($(this).val());
            $.ajax({
                url: "/ProjectMember/Create/",
                type: 'GET',
                data: {projectID: @Model.projectID, userName: $(this).val()},
                success: function (response) {
                    alert("Success!")

                },
                error: function () {
                    alert("error");
                }
            });

        });
    }); 
</script>
Remove member: 
@Html.DropDownList("projectMembers", String.Empty) 

<script type="text/javascript">
    $(document).ready(function () {
        $('#projectMembers').change(function () {
            //alert($(this).val());
            $.ajax({
                url: "/ProjectMember/RemoveMember/",
                type: 'GET',
                data: {projectID: @Model.projectID, userName: $(this).val()},
                success: function (response) {
                    alert("Success!")

                },
                error: function () {
                    alert("error");
                }
            });

        });
    }); 
</script>


<!-- $("#CurrentProjectData").html(response); !-->
<div>
    @Html.ActionLink("Back to List", "Index")
</div>
